package com.sxhnpg.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.sxhnpg.util.DBUtil;

public class TransactionInterceptor  extends MethodFilterInterceptor{

	public String doIntercept(ActionInvocation invocation) throws Exception {
		String resultCode;
		DBUtil.getConnection().setAutoCommit(false);
		try{
			resultCode=invocation.invoke();
			DBUtil.getConnection().commit();
			return resultCode;
		}catch (Exception e) {
			e.printStackTrace();
			DBUtil.closeConnection();
			throw e;
		}
	}
}
